package com.investment.advisor.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Set;

@Entity
@Table(name = "strategies")
@Getter
@Setter
@NoArgsConstructor
@ToString(exclude = {"strategyFactors", "portfolios"})
public class Strategy {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, length = 100)
    private String name;

    @Column(length = 1000)
    private String description;  // 策略描述

    @Column(length = 50)
    private String combinationMethod;  // 因子组合方式：等权重、自定义权重、优化权重

    @Column(length = 50)
    private String optimizeTarget;  // 优化目标：最大收益、最小风险、最大夏普比率

    @Column(length = 255)
    private String fundPool;  // 基金池：全部、股票型、混合型、债券型、指数型等

    @Column(length = 100)
    private String creator;  // 创建者

    @JsonManagedReference
    @OneToMany(mappedBy = "strategy", cascade = CascadeType.ALL)
    private Set<StrategyFactor> strategyFactors;  // 策略使用的因子及权重

    @JsonManagedReference
    @OneToMany(mappedBy = "strategy", cascade = CascadeType.ALL)
    private Set<Portfolio> portfolios;  // 基于该策略的组合

    @CreationTimestamp
    private LocalDateTime createTime;

    @UpdateTimestamp
    private LocalDateTime updateTime;
} 